package com.jsyh.maidu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jsyh.maidu.R;

import java.util.List;

/**
 * Created by ZHY_9 on 2017/7/18.
 */

public class PopUpAdapter extends RecyclerView.Adapter<PopUpAdapter.PopUpHolder> {

    List<String> key;
    List<String> value;
    Context context;

    public PopUpAdapter(List<String> key, List<String> value, Context context) {
        this.key = key;
        this.value = value;
        this.context = context;
    }

    @Override
    public PopUpHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_pop_up, null);
        PopUpHolder holder = new PopUpHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(PopUpHolder holder, int position) {
        holder.key.setText(key.get(position));
        holder.value.setText(value.get(position));
    }

    @Override
    public int getItemCount() {
        return key.size();
    }


    class PopUpHolder extends RecyclerView.ViewHolder {

        TextView key;
        TextView value;

        public PopUpHolder(View itemView) {
            super(itemView);
            key = (TextView) itemView.findViewById(R.id.pop_up_key);
            value = (TextView) itemView.findViewById(R.id.pop_up_value);
        }
    }
}
